<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>基础资料-库存查询</title>
<link rel="shortcut icon" href="favicon.ico">
<!-- FontAwesome 4.3.0 -->
<link href="{$fonts.url}font-awesome-4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<!-- Ionicons 2.0.1 -->
<link href="{$fonts.url}ionicons-2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css" />
<!--bootstrap-->
<link href="{$css.url}bootstrap_min.css" rel="stylesheet" type="text/css" />
<!--AdminLTE theme-->
<link href="{$css.url}AdminLTE_min.css" rel="stylesheet" type="text/css" />
<link href="{$css.url}AdminLT_skins/_all-skins.min.css" rel="stylesheet" type="text/css" />	
<!--datapicker-->
<link href="{$js.url}plugins/datapicker/datepicker.min.css" rel="stylesheet" type="text/css" />
<!--multiselect-->
<link href="{$js.url}plugins/multiselect/css/bootstrap-multiselect.css" rel="stylesheet" type="text/css" />
<!--web css-->
<link rel="stylesheet" href="{$css.url}product_manage_min.css">
<link href="{$css.url}main.css" rel="stylesheet" type="text/css" />
<!--[if lt IE 9]>
    <script src="{$js.url}plugins/html5shiv.min.js"></script>
    <script src="{$js.url}plugins/respond.min.js"></script>
<![endif]-->
{literal}
<style>
.box-body{min-height:350px;}
.table-toolbar .columns-right{position:relative;}
.table-toolbar .dropdown-menu{right:0;left:auto;max-height:340px;overflow:auto;}
.table-toolbar .dropdown-menu li{padding:5px 15px;}
.table-toolbar .dropdown-menu li p{margin:0;}
.img-thumbnail{width:50px;height:50px;}
.nav-tabs-custom{box-shadow:none;margin:10px 10px 0px 10px;}
</style>
{/literal}
</head>
<body class="skin-blue">
<div class="wrapper">
	{include file="bread_crumbs.php"}
	<!--引入面包屑-->
	<section class="base-setting-wrap">
		<div class="row">
			<div class="col-md-12">
				<div class="box">
					<div class="nav-tabs-custom">
						<ul class="nav nav-tabs">
					      <li class="active"><a href="/base/stock/index">子仓库库存查询</a></li>
					      <li><a href="/base/stock/basestocks">总仓库库存查询</a></li>					      
					    </ul>
				    </div>
	                <div class="box-header with-border clearfix">
	                	<div class="box-title pull-left">
	                		<a href="javascript:;" class="btn btn-primary btn-sm" id="illustration"><i class="fa fa-plus mr5"></i>库存说明查看</a>
	                	</div>
	                	<div class="box-form pull-right form-group-sm">
	                		<p class="pull-right"><a href="javascript:;" class="btn btn-success btn-sm" id="js_toggleSearchBox"><i class="fa fa-search"></i><span class="pl5">搜索选项</span></a></p>
	                	</div>
	                	<div class="clearfix"></div>
						<div class="search-box" id="js_searchBox">
							<form method="get" action="/base/stock/index" class="form-inline" id="search">
								<div class="form-group-sm">	
									<p>
										<label class="control-label">所属事业部：</label>
										<select class="form-control" name="dept_id" id="dept_id">
											<option value="">选择事业部</option>
											{foreach from=$depts item="vor"}
											<option {if $param.dept_id==$vor.id}selected=selected{/if} value="{$vor.id}">{$vor.department_name}</option>
											{/foreach}
										</select>
										<select class="form-control" name="warehouse_id" id="warehouse_id" style="width: 200px;">
										<option value="">选择仓库</option>
										</select>
										<label class="control-label">产品分类：</label>
										<select class="form-control" id="cat_id" deval='{$param.deval}'></select>
										<input type="hidden" name="select_cat_id" id="select_cat_id"/>&nbsp;
									</p>							
									<p class="no-margin">
										<label class="control-label ml10">生命周期：</label>
										<select class="form-control" id="life_cycle" name="life_cycle">
											<option value="">请选择</option>
											<option value="成长期" {if $param.life_cycle == '成长期'}selected{/if}>成长期</option>
											<option value="成熟期" {if $param.life_cycle == '成熟期'}selected{/if}>成熟期</option>
											<option value="衰败期" {if $param.life_cycle == '衰败期'}selected{/if}>衰败期</option>
											<option value="其它时期" {if $param.life_cycle == '其它时期'}selected{/if}>其它时期</option>
										</select>
										<label class="control-label ml10">搜索关键字类别：</label>
										<select class="form-control ml10" name="search_type">
			                				<option value="1" {if $param.search_type == 1}selected{/if}>产品编码</option>
			                				<option value="2" {if $param.search_type == 2}selected{/if}>产品名称</option>
		                				</select>
										<input type="text" class="form-control" name="searchName" value="{$param.searchName}">
										<button type="submit" id="search_button" class="btn btn-primary btn-sm">立即搜索</button>
										<a href="/base/stock/">清除搜索条件</a>
									</p>
								</div>
							</form>
						</div>
	                </div>
	                <!-- /.box-header -->
	                <div class="box-body">
	                  <table class="table table-bordered table-striped table-hover">
	                  	<thead>
	                    <tr>
	                      <th>产品图片</th>
	                      <th>产品编码</th>
	                      <th>产品名称</th>
	                      <th>产品分类</th>
	                      <th>仓库</th>
	                      <th>可用库存</th>
	                      <th>订货数量</th>
	                      <th>在途库存</th>
	                      <th>可配库存</th>
	                      <th>待发库存</th>
	                      <th>冻结库存</th>
	                      <th>不良品库存</th>
	                      <th style="width: 150px">备货销量</th>
	                      <th style="width: 150px">实际销量</th>
	                      <th>生命周期</th>
	                    </tr>
	                    </thead>
	                    {if isset($stock)&&$stock}
	                    {foreach from=$stock item="values"}
	                    	<tr>
								<td><a href="{$values.thumb_url}" target="_blank"><img src="{$values.goods_thumb}" class="img-thumbnail" width="50" height="50" data-toggle="tooltip" title="点击查看大图"></a></td>
								<td>{$values.goods_sn}</td>
								<td>{$values.product_name}</td>
								<td>{$values.name_ch}</td>
								<td>{$values.warehouse_name}</td>
								<td>{$values.base_stock}</td>
								<td>{$values.stock_order_nums}</td>
								<td>{$values.stock_on_way}</td>
								<td>{$values.stock_can_allot}</td>
								<td>{$values.stock_wait_for_send}</td>
								<td>{$values.frozen_stock}</td>
								<td>{$values.rejects_stock}</td>
								<td>
									前7天：{if $values.sale_7}{$values.sale_7}{else}0{/if}<br>
									前15天：{if $values.sale_15}{$values.sale_15}{else}0{/if}<br>
									前30天：{if $values.sale_30}{$values.sale_30}{else}0{/if}
								</td>
								<td>
									前7天：{if $values.real_sale_7}{$values.real_sale_7}{else}0{/if}<br>
									前15天：{if $values.real_sale_15}{$values.real_sale_15}{else}0{/if}<br>
									前30天：{if $values.real_sale_30}{$values.real_sale_30}{else}0{/if}
								</td>
								<td>{$values.life_cycle}</td>
							</tr>
	                    {/foreach}
	                    {/if}
	              	</table>
	                </div>
	                <!-- .box-body -->
	                <div class="box-footer text-center clearfix">{if isset($page)}{$page}{/if}</div>
	              </div>
			</div>
		</div>
	</section>
</div>

<script src="{$js.url}lib/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="{$js.url}lib/bootstrap.min.js" type="text/javascript"></script>
<script src="{$js.url}plugins/datapicker/bootstrap-datepicker-cn.js" type="text/javascript"></script>
<script src="{$js.url}plugins/multiselect/js/bootstrap-multiselect.js" type="text/javascript"></script>
<script src="{$js.url}plugins/layer.js" type="text/javascript"></script>  
<script src="{$js.url}plugins/zeroclipboard/ZeroClipboard.min.js" type="text/javascript"></script> 
<script src="{$js.url}plugins/jquery.validate.min.js" type="text/javascript"></script>
<script src="{$js.url}linkagesel-min.js" type="text/javascript"></script>
<script src="{$js.url}plugins/jquery.ztree.all-3.5.min.js" type="text/javascript"></script>
<script src="{$js.url}plugins/validate-methods.js"></script>
<!--common js-->
<script src="{$js.url}common.js"></script>
<link rel="stylesheet" type="text/css" href="{$js.url}plugins/select2/css/select2.min.css">	
<script type="text/javascript" src="{$js.url}plugins/select2/js/select2.min.js"></script>	
<script>
	var data = {$params};
	var del_id = 0;
	{literal}
	//var deptSplit = $("#dept_id").attr('deval').split(',');
	var strSplit = $("#cat_id").attr('deval').split(',');
	var opts = {
		ajax: '/widget/category/getcat',
		selClass:'form-control inline',
		selStyle: 'font-size:12px;font-family:;microsoft YaHei;',
		autoLink : false,
		defVal: strSplit,
		head: '所有分类',
		select: '#cat_id'
	};
	/*var dept = {
		ajax: '/system/user/getdept',
		selClass:'form-control inline',
		selStyle: 'font-size:12px;font-family:;microsoft YaHei;',
		autoLink : false,
		defVal: deptSplit,
		head: '所有部门',
		select:  '#dept_id'
	};*/
	var linkageSel = new LinkageSel(opts);
	// var linkageSe = new LinkageSel(dept);
	$('#search_button').click(function(){
		var v = linkageSel.getSelectedValue();
		//var d = linkageSe.getSelectedValue();
		$('#select_cat_id').val(v);
		// $('#select_dept_id').val(d);
	});
	$('#illustration').click(function (){
		layer.alert(
			'<p><b>说明：</b>该模块查询各个仓库的产品库存，除特殊说明之外数据全部是由WMS系统实时同步传输到备货系统（IFS）</p>' +
	 		'<p><b>可用库存：</b>仓库真实库存+在途库存—订单占用量（仓库真实库存=可配库存+待发库存），每天早上7点计算一次；</p>' + 
	 		'<p><b>订货数量：</b>采购已向供应商订货，但供应商还未交货的数量 ；</p>' + 
	 		'<p><b>在途库存：</b>采购已收货，产生送货单送往仓库途中的库存；</p>' + 
	 		'<p><b>可配库存：</b>未被订单占用的实际可配货库存，即货架上的库存；</p>' + 
	 		'<p><b>待发库存：</b>已被订单占用但实际还未出库的不可配货库存；</p>' + 
	 		'<p><b>冻结库存：</b>被冻结不可操作的库存；  不良品库存：不良品的库存。</p>',
	 		{
				skin: 'layui-layer-lan',
				closeBtn: 1,
				shift: 5,
				title:"厍存说明",
				area:["650px","auto"],
			}
		);
	});
	// 取仓库OPTION
	function warehouse(did){
		var did = !isNaN(did) ? did : $(this).find('option:selected').val();
		var str = '<option value="">选择仓库</option>';
		$.ajax({
			url : '/base/warehouse/getselectedwarehousebydeptid',
			data : {did : did},
			dataType : 'json',
			type : 'get',
			success : function (result){
				$.each(result, function(i, n){
					if(n.warehouse_code == data.warehouse_id){
						str += '<option value="' + n.warehouse_code + '" selected>' + n.warehouse_name + '</option>';
					}else{
						str += '<option value="' + n.warehouse_code + '">' + n.warehouse_name + '</option>';
					}
				});
				$('select[name="warehouse_id"]').html(str);
				$("#warehouse_id").select2();
			}
		});
	}
	//i saw your friend angin and we have chated for a while.
	warehouse(data.dept_id);
	$('#dept_id').change(warehouse);
	$('#examine_status option').each(function (){
		if($(this).val() == data.examine_status){
			$(this).attr('selected', 'selected');
			return false;
		}
	});
</script>
{/literal}
</body>
</html>